﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aras.IOM;

namespace ArasConnection
{
    public static  class AConnection
    {
        /// <summary>
        /// 获取所有的Aras 资料库
        /// </summary>
        /// <returns></returns>
        public static List<string> getArasPLMDatabases()
        {
            string[] DataBases=  PublicState.ArasConnection.GetDatabases();
            List<string> myReturn = new List<string>();
            foreach (string s in DataBases)
                myReturn.Add(s);
            return myReturn;
        }
        /// <summary>
        /// 检查Aras 登陆验证
        /// </summary>
        /// <returns></returns>
        public static bool checkArasLogin()
        {
            PublicState.ArasLoginItem = PublicState.ArasConnection.Login();
            if (PublicState.ArasLoginItem.isEmpty() || PublicState.ArasLoginItem.isError())
            {
                return false;
            }
            else
            {
                PublicState.ArasLoginInnovator = PublicState.ArasLoginItem.getInnovator();
                return true;
            }
        }
        public static string getLoginUserName()
        {
            try
            {
                return PublicState.ArasLoginInnovator.getUserAliases();
            }
            catch
            {
                return "";
            }
        }
    }
}
